import {CURRENT_TOKEN} from "@/components/Authorized/renderAuthorize";
import {request} from "umi";
import URLS from "./APIUrlDefine";

export const SUCCESS_CODE = 10000;

/**
 * 根据id删除指定角色
 * @param id
 */
export async function SaveConfig(data: string) {
  return request(`${URLS.SAVE_SEBSITE_CONFIG}`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${CURRENT_TOKEN}`,
    },
    params: {config: data}
  });
}

/**
 * 根据id删除指定角色
 * @param id
 */
export async function GetConfig() {
  return request(`${URLS.GET_WEBSITE_CONFIG}`, {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${CURRENT_TOKEN}`,
    },
  });
}

export function DownLoadFile(url: string) {
  const a = document.createElement("a");
  a.href = url;
  $("body").append(a); // 修复firefox中无法触发click
  a.click();
  $(a).remove();
}
